package club.kingyin.kyblog.core.business.service.admin;

import club.kingyin.kyblog.core.business.mapper.DocMapper;
import club.kingyin.kyblog.core.business.mapper.TypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Set;

/**
 * @author : kingyins
 * @version : 1.0
 * @program : ky-blog
 * @description : 在此处添加类描述
 * @create : 2021年08月25日 15:19
 **/
@Service
public class TypeService {

    @Autowired
    private TypeMapper typeMapper;

    public Set<String> getTypes() {
        try {
            return typeMapper.selectTypes();
        } catch (Exception e) {
            return null;
        }
    }

    public boolean updateType(String sources, String target) {
        try {
            return typeMapper.updateType(sources, target) > 0;
        } catch (Exception e) {
            return false;
        }
    }

    public boolean deleteType(String sources) {
        try {
            return typeMapper.deleteType(sources) > 0;
        } catch (Exception e) {
            return false;
        }
    }

    public boolean addTypes(ArrayList<String> types) {
        try {
            return typeMapper.insert(types) > 0;
        } catch (Exception e) {
            return false;
        }
    }
}
